package org.htmlparser.filters;

import org.htmlparser.Node;
import org.htmlparser.NodeFilter;
import org.htmlparser.Tag;
import org.htmlparser.util.NodeList;

public class HasSiblingFilter
  implements NodeFilter
{
  protected NodeFilter mSiblingFilter;

  public HasSiblingFilter()
  {
    this(null);
  }

  public HasSiblingFilter(NodeFilter paramNodeFilter)
  {
    setSiblingFilter(paramNodeFilter);
  }

  public boolean accept(Node paramNode)
  {
    int i = 0;
    if ((!(paramNode instanceof Tag)) || (!(((Tag)paramNode).isEndTag())))
    {
      Node localNode = paramNode.getParent();
      if (localNode != null)
      {
        NodeList localNodeList = localNode.getChildren();
        if (localNodeList != null)
        {
          int j = localNodeList.size();
          for (int k = 0; (i == 0) && (k < j); ++k)
            if (getSiblingFilter().accept(localNodeList.elementAt(k)))
              i = 1;
        }
      }
    }
    return i;
  }

  public NodeFilter getSiblingFilter()
  {
    return this.mSiblingFilter;
  }

  public void setSiblingFilter(NodeFilter paramNodeFilter)
  {
    this.mSiblingFilter = paramNodeFilter;
  }
}